/**
 * 菜单路由模块
 */

const Router = require('koa-router');
const router = new Router();
const { add, update, deleteMenu, getList, getListByTeacherId, getListByRoleId } = require('../services/menus');
const { validateAdd, validaUpdate, validMenuId, validRoleId } = require('../validators/menus');
const { validate } = require('../validators/common');

router.prefix('/menus');

/**
 * 添加菜单
 */
router.post('/add', validate(validateAdd), add);

router.put('/update', validate(validaUpdate), update);

router.delete('/delete/:id', validate(validMenuId), deleteMenu);

router.get('/list', getList);

router.get('/rightsList', getListByTeacherId);

router.get('/listByRole/:id', validate(validRoleId), getListByRoleId);

module.exports = router;